package com.sojson.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.dao.ArticleDao;
import com.sojson.entity.bo.Select;
import com.sojson.entity.po.Article;
import com.sojson.service.ArticleService;

/**
 * 文章分类表Service实现类
 * 
 * @author liu
 * @date 2021-03-16
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleDao articleDaoImpl;

    /**
     * 单条插入
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(Article article) {
        int insert = articleDaoImpl.insert(article);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(Article article) {
        int insertList = articleDaoImpl.insertList(article.getArticles());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(Article article) {
        int deleteByDto = articleDaoImpl.deleteByDto(article);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        int countAll = articleDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<Article> findAll() {
        List<Article> findAll = articleDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(Article article) {
        int countByDto = articleDaoImpl.countByDto(article);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public List<Article> findByDto(Article article) {
        List<Article> findByDto = articleDaoImpl.listByDto(article);
        return findByDto;
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        int deleteById = articleDaoImpl.deleteById(id);
        return deleteById;
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(ArrayList<Integer> ids) {
        int deleteByIdList = articleDaoImpl.deleteByIdList(ids);
        return deleteByIdList;
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(Article article) {
        int updateById = articleDaoImpl.updateById(article);
        return updateById;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(Article article) {
        int updateStaticByIdList = articleDaoImpl.updateStaticByIdList(article);
        return updateStaticByIdList;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(Article article) {
        int updateChangeByIdList = articleDaoImpl.updateChangeByIdList(article.getArticles());
        return updateChangeByIdList;
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(Article article) {
        int updatePartialById = articleDaoImpl.updatePartialById(article);
        return updatePartialById;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(Article article) {
        int updateStaticPartialByIdList = articleDaoImpl.updateStaticPartialByIdList(article);
        return updateStaticPartialByIdList;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(Article article) {
        int updateChangePartialByIdList = articleDaoImpl.updateChangePartialByIdList(article.getArticles());
        return updateChangePartialByIdList;
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public Article findById(Integer id) {
        Article findById = articleDaoImpl.findById(id);
        return findById;
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Article> findByIdList(ArrayList<Integer> ids) {
        ArrayList<Article> findByIdList = articleDaoImpl.findByIdList(ids);
        return findByIdList;
    }

    /**
     * 通过对象查询id列表
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findIdByDto(Article article) {
        ArrayList<Integer> findIdByDto = articleDaoImpl.findIdByDto(article);
        return findIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        articleDaoImpl.clear();
    }

    /**
     * 根据对象查询
     * 
     * @param article
     * @return
     * @throws SQLException
     */
    @Override
    public List<Select> findSelect(Article article) {
        return articleDaoImpl.findSelect(article);
    }

}